<template>
  <div>
      <!-- 头部部分 -->
    <header class="header">
      <h1>todos</h1>
      <input class="new-todo" placeholder="请输入任务名称" autofocus
      v-model.trim="todoList"  @keyup.enter="addList"/>
    </header>
  </div>
</template>

<script>
export default {
  data(){
    return{
      todoList:''
    }
  },
  methods:{
    addList(){
      if(!this.todoList) return alert('输入的值不能为空！')
      this.$emit('addList',this.todoList)
      this.todoList=''
    }
  }

}
</script>

<style>

</style>